package com.bluejie.springBoot.configuration;

import com.bluejie.springBoot.filter.BluejFilter;
import org.apache.catalina.filters.RemoteIpFilter;
import org.springframework.boot.web.servlet.FilterRegistrationBean;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import java.util.HashMap;
import java.util.Map;
import java.util.Objects;

/**
 * Created by bluej on 2018-03-19.
 */
@Configuration
public class WebConfiguration {
    @Bean
    public RemoteIpFilter remoteIpFilter(){
        return new RemoteIpFilter();
    }

    @Bean
    public FilterRegistrationBean bluejFilterRegistrationBean(){
        FilterRegistrationBean filterRegistrationBean = new FilterRegistrationBean();
        filterRegistrationBean.setFilter(new BluejFilter());
        filterRegistrationBean.setName("bluejFilter");
        filterRegistrationBean.addUrlPatterns("/**");
        filterRegistrationBean.setOrder(1);
        filterRegistrationBean.addInitParameter("paramName","paramName");
        return filterRegistrationBean;
    }
}
